package com.iyundao.io.mapper;

import com.iyundao.io.model.SysLog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

@Repository
public interface SysLogMapper {
    @Delete({
        "delete from sys_log",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(String sid);

    @Insert({
        "insert into sys_log (sid, operation_name, ",
        "operation_type, parameter, ",
        "results, sys_msg, ",
        "create_date, create_id)",
        "values (#{sid,jdbcType=CHAR}, #{operationName,jdbcType=VARCHAR}, ",
        "#{operationType,jdbcType=VARCHAR}, #{parameter,jdbcType=VARCHAR}, ",
        "#{results,jdbcType=VARCHAR}, #{sysMsg,jdbcType=VARCHAR}, ",
        "#{createDate,jdbcType=TIMESTAMP}, #{createId,jdbcType=CHAR})"
    })
    int insert(SysLog record);

    @InsertProvider(type=SysLogSqlProvider.class, method="insertSelective")
    int insertSelective(SysLog record);

    @Select({
        "select",
        "sid, operation_name, operation_type, parameter, results, sys_msg, create_date, ",
        "create_id",
        "from sys_log",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    @Results({
        @Result(column="sid", property="sid", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="operation_name", property="operationName", jdbcType=JdbcType.VARCHAR),
        @Result(column="operation_type", property="operationType", jdbcType=JdbcType.VARCHAR),
        @Result(column="parameter", property="parameter", jdbcType=JdbcType.VARCHAR),
        @Result(column="results", property="results", jdbcType=JdbcType.VARCHAR),
        @Result(column="sys_msg", property="sysMsg", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_date", property="createDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_id", property="createId", jdbcType=JdbcType.CHAR)
    })
    SysLog selectByPrimaryKey(String sid);

    @UpdateProvider(type=SysLogSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(SysLog record);

    @Update({
        "update sys_log",
        "set operation_name = #{operationName,jdbcType=VARCHAR},",
          "operation_type = #{operationType,jdbcType=VARCHAR},",
          "parameter = #{parameter,jdbcType=VARCHAR},",
          "results = #{results,jdbcType=VARCHAR},",
          "sys_msg = #{sysMsg,jdbcType=VARCHAR},",
          "create_date = #{createDate,jdbcType=TIMESTAMP},",
          "create_id = #{createId,jdbcType=CHAR}",
        "where sid = #{sid,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(SysLog record);
}